package com.chance.cc.crawler.development.bootstrap.baidu.yidianzixun;

import com.chance.cc.crawler.core.CrawlerEnum;
import com.chance.cc.crawler.core.downloader.proxy.Proxy;
import com.chance.cc.crawler.core.filter.FilterUtils;
import com.chance.cc.crawler.core.record.CrawlerRequestRecord;
import com.chance.cc.crawler.development.controller.DevCrawlerController;

public class YiDianStart {
    public static final String domain = "baidu";
    public static final String site = "YDZX";

    private static Proxy proxy = new Proxy();
    static {
        //代理配置
        //H5168QRFNIU3804D
        //5F6B3610BB719FAA
        proxy.setHost("http-dyn.abuyun.com");
        proxy.setPort(9020);
        proxy.setUsername("HL89Q19E86E2987D");
        proxy.setPassword("71F33D94CE5F7BF2");
    }
    public static void main(String[] args) {


        CrawlerRequestRecord requestRecord = CrawlerRequestRecord.builder()
                .startPageRequest(domain, CrawlerEnum.CrawlerRequestType.turnPage) //turnpage 翻页
                .domain(domain)
                .httpUrl("https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=2&tn=baiduhome_pg&wd=nike&ct=2097152&si=yidianzixun.com&rsv_spt=1&oq=%25E4%25BD%25A0%25E5%258F%25AF&rsv_pq=ee20d1a400086822&rsv_t=f4f8FMnYzwUdyaEUWNM9k%2FPCbVNSJwbS2G%2BSL1zWBm3Klv6VDJZhyToC2kkIdXGDs7qy&rqlang=cn&rsv_enter=1&rsv_dl=tb&rsv_btype=t&inputT=2580&rsv_sug3=7&rsv_sug1=7&rsv_sug7=100&rsv_jmp=slow")
                .recordKey("https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=2&tn=baiduhome_pg&wd=nike&ct=2097152&si=yidianzixun.com&rsv_spt=1&oq=%25E4%25BD%25A0%25E5%258F%25AF&rsv_pq=ee20d1a400086822&rsv_t=f4f8FMnYzwUdyaEUWNM9k%2FPCbVNSJwbS2G%2BSL1zWBm3Klv6VDJZhyToC2kkIdXGDs7qy&rqlang=cn&rsv_enter=1&rsv_dl=tb&rsv_btype=t&inputT=2580&rsv_sug3=7&rsv_sug1=7&rsv_sug7=100&rsv_jmp=slow")
                .releaseTime(System.currentTimeMillis())
                .filter(CrawlerEnum.CrawlerRecordFilter.keyOrDateRange)
                .addFilterInfo(FilterUtils.memoryFilterKeyInfo(domain))
                .addFilterInfo(FilterUtils.dateRangeFilterInfo(7 * 24, null))
                .proxy(proxy)
                .build();

           requestRecord.tagsCreator().bizTags().addDomain(domain);
           requestRecord.tagsCreator().bizTags().addSite(site);


        DevCrawlerController.builder()
                .crawlerThreadNum(10)
                .triggerInfo(domain, domain, System.currentTimeMillis(), domain)
                .crawlerRequestQueue(DevCrawlerController.devRequestQueue(domain))  //管道
                .consoleResultPipeline() //控制台输出
                .fileResultPipeline("D:\\chance\\log\\yidianzixun.log", false) //文件输出
                .requestRecord(requestRecord)
                .build("com.chance.cc.crawler.development.scripts.baidu.yidianzixun")
                .start();
    }


}
